home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / jmod310.zip / JMODEM_G.ASM < prev    next >
Assembly Source File  |  1991-11-30  |  3KB  |  92 lines

  1. TITLE   JMODEM_G.ASM
  2.  
  3. COMMENT *
  4.     Created        20-NOV-1991        Richard B. Johnson
  5.  
  6.     With the increased emphasis upon data transfer speed, it has
  7.     become necessary to move the interrupt service routines out
  8.     of the 'C' code and into assembly where they belong. Many will
  9.     remember that JMODEM was originally written in assembly language.
  10.  
  11.     With this modification, JMODEM can now operate at about 76,800
  12.     baud with a 33 MHz '386 clone and can operate at 38,400 baud with
  13.     a 12 MHz "True Blue" AT.
  14. *
  15. ;
  16.  
  17. EOI    EQU    20H            ; Non-specific end-of-interrupt
  18. INT_CTL    EQU    20H            ; Interrupt controller base address
  19.  
  20. _TEXT    SEGMENT  WORD PUBLIC 'CODE'
  21. _TEXT    ENDS
  22. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  23. _DATA    ENDS
  24. CONST    SEGMENT  WORD PUBLIC 'CONST'
  25. CONST    ENDS
  26. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  27. _BSS    ENDS
  28. DGROUP    GROUP    CONST, _BSS, _DATA
  29.     ASSUME DS: DGROUP, SS: DGROUP
  30. EXTRN    _write_ptr:WORD
  31. EXTRN    _buff_limit:WORD
  32. EXTRN    _hardware_port:WORD
  33. EXTRN    _timer:WORD
  34. EXTRN    _old_tim:DWORD
  35. PUBLIC    _tim_int
  36. PUBLIC    _com_int
  37.  
  38. _TEXT    SEGMENT WORD PUBLIC 'CODE'
  39.     ASSUME    CS: _TEXT
  40. ;
  41. ;    Communications hardware interrupt. To make this code as fast as
  42. ;    possible, only the registers actually used are saved on the stack.
  43. ;    Also, no jumps that could force the prefetch buffer to be flushed
  44. ;    are used.
  45. ;
  46. _com_int    PROC FAR
  47.     PUSH    AX                ; Save registers used
  48.     PUSH    BX
  49.     PUSH    DX
  50.     PUSH    DS
  51.     MOV    AX,DGROUP            ; Get data group
  52.     MOV    DS,AX                ; Set up segment
  53.     ASSUME  DS:DGROUP            ; Tell Assembler
  54.     MOV    DX,WORD PTR _hardware_port    ; Get port in use
  55.     IN    AL,DX                ; Get byte
  56.     MOV    BX,WORD PTR _write_ptr        ; Get buffer pointer
  57.     MOV    BYTE PTR [BX],AL        ; Put byte in the buffer
  58.     CMP    BX,WORD PTR _buff_limit        ; Check the buffer end
  59.     ADC    WORD PTR _write_ptr,0        ; Bump if not end of buffer
  60.     MOV    AL,EOI                ; Get end-of interrupt
  61.     OUT    INT_CTL,AL            ; Reset the controller
  62.     POP    DS                ; Restore segments used
  63.     POP    DX
  64.     POP    BX
  65.     POP    AX
  66.     IRET
  67. _com_int    ENDP
  68. ;
  69. ;    Hardware timer interrupt attached to INT 1CH. Its purpose is to
  70. ;    provide a fixed timout interval for error trapping without regard
  71. ;    for the CPU speed.
  72. ;
  73. _tim_int    PROC    FAR
  74.     PUSH    AX            ; Save register used
  75.     MOV    AL,EOI            ; Get end-of interrupt
  76.     OUT    INT_CTL,AL        ; Reset the controller right now!
  77.     STI                ; Allow all interrupts now
  78.     PUSH    DS            ; Save segment
  79.     MOV    AX,DGROUP        ; Get data GROUP
  80.     MOV    DS,AX            ; Make addressable
  81.     SUB    WORD PTR _timer,1    ; Bump the timer
  82.     ADC    WORD PTR _timer,0    ; Adjust if it went below zero
  83.     PUSHF                ; Set up for IRET from routine
  84.     CALL    DWORD PTR _old_tim    ; Call old timer interrupt
  85.     POP    DS            ; Restore segment
  86.     POP    AX            ; Restore register used
  87.     IRET
  88. _tim_int    ENDP
  89. ;
  90. _TEXT    ENDS
  91.     END
  92.